#!usr/bin/python
# -*- coding: UTF-8 -*-
class Rectangle:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def getPeri(self):
        return (self.x + self.y) * 2
    def getArea(self):
        return self.x * self.y

rect = Rectangle(3, 4)
print('a', rect.getPeri())
print('b', rect.getArea())

class A:
    def __init__(self):
        return 'A fo A-Cup'

#a = A() 报错TypeError: __init__() should return None, not 'str',因为第一个被调用的是__new__方法，而不是__init__

class CapStr(str):
    def __new__(cls, string):
        string = string.upper()
        return str.__new__(cls, string)

a = CapStr('I love python!')
print(a)

class C:
    def __init__(self):
        print('我是__init__方法，我被调用了...')
    def __del__(self):
        print('我是__del__方法，我被调用了...')

c1 = C()
c2 = c1
c3 = c2
#del c3
#del c2
#del c1











